<?php
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
#	FILE:			includes/flash/generatepagelist.php
#	FUNCTION:		Generates an XML document of pages in the current site
#	AUTHOR:			Cameron Morrow
#	CREATED:		26/07/2005
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Report all errors
error_reporting(E_ALL);

# Start session
session_start();

# Use this for IE to remember form data correctly
header("Cache-control: private");

# Vars
$ERROR_ARRAY = array();
$SQL_ARRAY = array();

# XML
header("content-type: text/xml");

# Includes
include "../site_specific/project.php";
include "../includes/constants.php";
include "../site_specific/external_constants.php";
include "../includes/phpmailer/class.phpmailer.php";
include "../includes/phpmailer/class.smtp.php";
include "../includes/utilities.php";
include "../includes/pages.php";
include "../includes/database.php";
include "../includes/users.php";
include "../includes/date.php";
include "../includes/text.php";
include "../includes/files.php";


# Establish database connection
establishDatabaseConnection();

#Grab glossary from database
$sql="SELECT * FROM ".$PROJECT_DB_TABLES["glossary"];

$current_data=getRecord($sql);

#Get distinct glossary letter
$sql_letter="SELECT DISTINCT gl_letter FROM ".$PROJECT_DB_TABLES["glossary"]." order by gl_term";

$current_Letter=getRecord($sql_letter);

echo "<Glossary>";
#Generate XML
Foreach($current_Letter as $key_letter=>$value_letter){
	
	
	echo "<Category Letter=\"".$value_letter["gl_letter"]."\">";//Output the Category with according to letter
	Foreach($current_data as $key_data=>$value_data){
		
		if($value_data["gl_letter"]==$value_letter["gl_letter"]){
			
			echo "<Item>";
			#Output the Term
			echo "<Term><![CDATA[".$value_data["gl_term"]."]]></Term>";
			#Output the Description
			/*echo "<Description>";		
				
				echo "<![CDATA[".$value_data["gl_descripto"]."]]>";
						
			echo "</Description>";*/
			
			echo "<Description><![CDATA[".$value_data["gl_descripto"]."]]></Description>";
			echo "</Item>";		
		}
		
	}
	echo "</Category>";	
}

echo "</Glossary>";
?>